//
//  UIBarButtonItem + Extension.swift
//  SwiftFreshBeen
//
//  Created by Apple on 16/12/22.
//  Copyright © 2016年 zhouwnegang. All rights reserved.
//

import Foundation
import UIKit

extension UIBarButtonItem {
    
    //重写自定义构造方法
    convenience init(title:String = "" ,imageName:String,target:Any?,action:Selector?) {
        
        let btn = UIButton()
        btn.setTitle(title, for: .normal)
        btn.setImage(UIImage(named:imageName), for: .normal)
        
        btn.sizeToFit()
        
        if let ac = action {
            btn.addTarget(target, action: ac, for: .touchUpInside)
        }
            
        
        self.init()
        
        //设置自定义视图
        self.customView = btn
        
        
    }
}
